<?php
/*
*	Kleophatra - Open Source Content Management System
*	------------------------------------------------------------------------
*	Copyright (C) 2007-2009, Sergio Milardovich <smilardovich@yahoo.com.ar>
*	This program is Free Software.
*	Feeds generator library for kleophatra content management system.
*
*	@package	Kleophatra
*	@subpackage	/lib
*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
*	@author		Sergio Milardovich <smilardovich@yahoo.com.ar>
*	@link		http://www.kleophatra.org
*/

class kleofeeds extends kleotemplate{
  var $format = 'ATOM'; //ATOM, RSS or RSS2
  var $encoding = 'utf-8';
  var $title = $this->get_core_value('web_title');
  var $subtitle = $this->get_core_value('web_slogan');
  var $author_name = $this->get_core_value('admin_name');
  var $author_email = $this->get_core_value('admin_email');
  var $limit = (int)$this->get_core_value('feeds_entries_limit');
  var $id = $this->get_core_value('siteurl');
  
  function generate_feed($query){

    $feed = $this->tpl_load(KLEO_MODULES_DIR.'feeds/views/'.strtolower($this->format).'.xml', $feed);
    $this->tpl_set(
      array(
	"FEED_TITLE" => $this->title,
	"FEED_SUBTITLE" => $this->subtitle,
	"ID" => $this->id
      ), false, $feed, $feed
    );
    $feed_entries;
    while($row = $this->fetch_array($query)){
      $feed_entries_file = $this->tpl_load(KLEO_MODULES_DIR.'feeds/views/'.strtolower($this->format).'_entries.xml', $feed_entries_file);
      $this->tpl_set(
	array(
	  "FEED_TITLE" => $row['title']
	)
      )
      $feed_entries .= $feed_entries_file;
    }
  }
}
